#!/bin/bash
print_page_fault_count() {
    echo -e "$(date '+%Y-%m-%d %k:%M:%S %N'): page_fault_count: $1"
}

if [ "$1" != "" ]; then
    interval=$1
else
    interval=1
fi

page_fault_count_old=$(cat /proc/page_fault_count)
print_page_fault_count $page_fault_count_old

while [ "1" ]; do
    sleep $interval
    page_fault_count_new=$(cat /proc/page_fault_count)
    sub=$((page_fault_count_new - page_fault_count_old))
    print_page_fault_count $sub
    page_fault_count_old=$page_fault_count_new
done
